package com.cdl.collectiontest;

import java.util.LinkedList;

public class LinkdeListTest {

    public static void main(String[] args) {


        LinkedList queue = new LinkedList();
        queue.addFirst("1");
        queue.addFirst("2");
        queue.addFirst("3");
        queue.addFirst("4");
        queue.addFirst("5");
        queue.addFirst("6");

        System.out.println(queue);

        for (int i = 0; i < 3; i++) {
            System.out.println(queue.removeFirst());
        }

        System.out.println(queue);



        //使用索引号
        LinkedList<String> animals = new LinkedList<>();
        animals.add(0,  "cat");
        animals.add(1, "dog");
        animals.add(2, "cat");
        System.out.println("animals: " + animals);

        queue.addAll(animals);
        System.out.println("queue: " + queue);

    }
}
